// import Vue from 'vue'
import debounce from './debounce'
import hasPermi from './hasPermi'
import drag from './drag'

const install = function(Vue) {
  Vue.directive('debounce', {
    bind(el, binding) {
      let executeFunction
      if (binding.value instanceof Array) {
        const [func, time = 1000] = binding.value
        executeFunction = debounce(func, time)
      } else {
        executeFunction = debounce(binding.value, 1000)
      }
      el.addEventListener('click', executeFunction)
    }
  })
  Vue.directive('hasPermi', hasPermi)
  Vue.directive('el-drag-dialog', drag)
}

export default install
